package tests;

import java.util.ArrayList;
import java.util.List;

import lib.logging.ILogger;

/**
 * Mock implementation of ILogger for use in unit tests
 * 
 * @implements {@link ILogger}
 * @author abhip
 * 
 */
public class TestLogger implements ILogger {
    private List<String> errorCalls;
    private List<String> exceptionCalls;
    private List<String> infoCalls;

    public TestLogger() {
        infoCalls = new ArrayList<String>();
        errorCalls = new ArrayList<String>();
        exceptionCalls = new ArrayList<String>();
    }

    public List<String> ErrorCalls() {
        return errorCalls;
    }

    public int ErrorCallsCount() {
        return errorCalls.size();
    }

    public List<String> ExceptionCalls() {
        return exceptionCalls;
    }

    public int ExceptionCallsCount() {
        return exceptionCalls.size();
    }

    public List<String> InfoCalls() {
        return infoCalls;
    }

    public int InfoCallsCount() {
        return infoCalls.size();
    }

    /**
     * Keeps track of error messages
     * 
     * @param errorFormatString
     * @param args
     */
    @Override
    public void LogError(String errorFormatString, Object... args) {
        errorCalls.add(String.format(errorFormatString, args));
    }

    /**
     * Keeps track of exceptions
     * 
     * @param e
     */
    @Override
    public void LogException(Exception e) {
        exceptionCalls.add(e.toString());
    }

    /**
     * Keeps track of info messages
     * 
     * @param infoFormatString
     * @param args
     */
    @Override
    public void LogInfo(String infoFormatString, Object... args) {
        infoCalls.add(String.format(infoFormatString, args));
    }
}
